<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="inc/taglibs.jsp" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <%@ include file="inc/meta.jsp" %>
    <meta name="description" content="">
    <meta name="author" content="">
    <title>控制面板</title>
    <%@ include file="inc/css.jsp" %>
</head>

<style>
    .textAling {
        text-align: center;
    }
</style>

<body>

<div id="posts" class="wrapper">
    <%@ include file="inc/nav.jsp" %>
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header" style="text-align: center;">${adminUser.account}，欢迎进入52Hz后台管理系统</h1>
            </div>
            <!-- /.col-lg-12 -->
        </div>

        <div class="panel-body">
            <h3>用户统计信息</h3>

            <div class="col-sm-12">
                <table class="table table-striped table-bordered table-hover">
                    <colgroup>
                        <col class="gradeA odd"/>
                        <col class="gradeA even"/>
                        <col class="gradeA odd"/>
                        <col class="gradeA even"/>
                    </colgroup>
                    <thead>
                    <tr>
                        <td width="25%;" class="textAling">新增用户数</td>
                        <td width="25%;" class="textAling">${todayUserCount}</td>
                        <td width="25%;" class="textAling">周增用户数</td>
                        <td width="25%;" class="textAling">${weekUserCount}</td>
                    </tr>
                    <tr>
                        <td width="25%;" class="textAling">月增用户数</td>
                        <td width="25%;" class="textAling">${monthUserCount}</td>
                        <td width="25%;" class="textAling">总用户数</td>
                        <td width="25%;" class="textAling">${allUserCount}</td>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>

        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading" style="height: 70px">
                        <form class="navbar-form navbar-right" role="search">
                            <div class="form-group">
                                <input type="text" class="form-control" id="nickName" maxlength="20" placeholder="昵称"/>
                            </div>
                            <div class="form-group">
                                <input type="text" class="form-control" id="num" maxlength="20" placeholder="购买物品"/>
                            </div>
                            <div class="form-group">
                                <input type="text" class="form-control input-append date form_datetime" style="width: 180px;" readonly id="startTime" maxlength="20" placeholder="开始时间"/>
                            </div>
                            <div class="form-group">
                                <input type="text" class="form-control input-append date form_datetime" style="width: 180px;" readonly id="endTime" maxlength="20" placeholder="结束时间"/>
                            </div>
                            <button type="button" id="c_search" class="btn btn-primary btn-sm">搜索</button>
                        </form>
                    </div>
                    <!-- /.panel-heading -->
                    <div class="panel-body">

                        <div class="table-responsive">

                            <table class="table table-striped table-bordered table-hover" id="dataTables">
                                <colgroup>
                                    <col class="gradeA odd"/>
                                    <col class="gradeA even"/>
                                    <col class="gradeA odd"/>
                                    <col class="gradeA even"/>
                                    <col class="gradeA odd"/>
                                </colgroup>
                                <thead>
                                <tr>
                                    <th>用户昵称</th>
                                    <th>购买物品</th>
                                    <th>合计购买金额</th>
                                    <th>购买时间</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>

                    </div>
                    <!-- /.panel-body -->

                </div>
                <!-- /.panel -->
            </div>
        </div>

    </div>

</div>

<%@ include file="inc/footer.jsp" %>
</body>

<script type="text/javascript">
    var _gainList = {
        v: {
            id: "_gainList",
            list: [],
            dTable: null,
            userMoneyId: 0
        },
        fn: {
            init: function () {
                _gainList.fn.dataTableInit();

                $('.form_datetime').datetimepicker({
                    language: 'zh-CN',
                    weekStart: 1,
                    todayBtn: 1,
                    autoclose: 1,
                    todayHighlight: 1,
                    startView: 2,
                    forceParse: 0,
                    showMeridian: 1,
                    format: 'yyyy-mm-dd hh:ii:ss'
                });

                // 查询
                $("#c_search").click(function () {
                    _gainList.v.dTable.ajax.reload();
                });
            },
            dataTableInit: function () {
                _gainList.v.dTable = $leoman.dataTable($('#dataTables'), {
                    "processing": true,
                    "serverSide": true,
                    "searching": false,
                    "ordering": false,
                    "ajax": {
                        "url": "backend/finance/buyList",
                        "type": "POST"
                    },
                    "columns": [
                        {"data": "user.nickName"},
                        {"data": "num"},
                        {"data": "money"},
                        {
                            "data": "createTime",
                            render: function (data) {
                                return formatJsonDateTime(data, 'yyyy-MM-dd hh:mm:ss');
                            }
                        },
                        {"data": ""}
                    ],
                    "columnDefs": [
                        {
                            "data": null,
                            "defaultContent": "<a title='查看明细' class='btn btn-primary btn-circle showInfo'>" +
                            "<i class='fa fa-eye'></i>" +
                            "</a>",
                            "targets": -1
                        }
                    ],
                    "createdRow": function (row, data, index) {
                        _gainList.v.list.push(data);
                    },
                    rowCallback: function (row, data) {
                        $('td', row).last().find(".showInfo").click(function () {
                            if (data.sourceType == 1) {
                                window.location.href = 'backend/letter/add?letterId=' + data.sourceId;
                            } else if (data.sourceType == 2) {
                                window.location.href = 'backend/letter/accept/info?letterAcceptId=' + data.sourceId;
                            } else {
                                window.location.href = 'backend/paper/add?paperId=' + data.sourceId;
                            }
                        });
                    },
                    "fnServerParams": function (aoData) {
                        aoData.nickName = $('#nickName').val();
                        aoData.num = $('#num').val();
                        aoData.startTime = $('#startTime').val();
                        aoData.endTime = $('#endTime').val();
                    },
                    "fnDrawCallback": function (row) {
                        $leoman.uiform();
                    }
                });
            }
        }
    }

    $(document).ready(function () {
        _gainList.fn.init();
    });

</script>

</html>